<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>课程二作业1</title>
</head>
<body>
        <span>编写python代码统计输入的字符串中字母和数字的个数，并输出。   </span>
        <p>输入:hello world! 123 </p>
        <p>输出：10个字母，3个数字</p>
        <p>代码：</p>
        <pre>
        def charNum(s):

            cnt = 0;

            count = 0;

            for i in s:

                if i.isalpha():

                    cnt += 1

                elif i.isalnum():

                    count += 1;

                else:

                    continue

            print(f"字母数量为：{cnt}")

            print(f"数字数量为：{count}")

        if __name__ == '__main__':

            s = input("请输入字符串：")

            charNum(s)
        </pre>
</body>
</html>